home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
ici
/
ici.cpi
/
tst-del.ici
< prev
next >
Wrap
Text File
|
1994-10-27
|
865b
|
50 lines
/*
* Work the del() function with random data.
*/
auto victim = [struct];
auto state = [struct];
auto i;
auto e;
auto v;
for (i = 0; i < 100; ++i)
{
switch (int(rand() * 2) % 2)
{
case 0:
/*
* Add a random element, give it a distinct value, and record
* that it should be present.
*/
e = int(rand() * 100);
victim.(e) = e * 10;
state.(e) = 1;
break;
case 1:
/*
* Delete a random element, and record that it should be absent.
*/
e = int(rand() * 100);
del(victim, e);
state.(e) = 0;
break;
}
/*
* Check the state of the victim against the recorded state.
*/
forall (v, e in state)
{
if (v)
{
if (victim.(e) != e * 10)
fail(sprintf("wrong value at pass %d of del() test", i));
}
else
{
if (victim.(e) != NULL)
fail(sprintf("value not NULL at pass %d of del() test", i));
}
}
}